using System;
using System.Collections.Generic;
using System.Net;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Data;

namespace Ratman.SharePoint.SPTwitter
{
    internal static class Http
    {
        internal static DataSet Get(string page, string vars, NetworkCredential cred)
        {
            DataSet _DataSet = new DataSet();

            HttpWebRequest _HttpWebRequest = (HttpWebRequest)WebRequest.Create(string.Format("{0}{1}", page, vars));

            _HttpWebRequest.Method = "GET";

            if (cred != null)
            {
                _HttpWebRequest.Credentials = cred;
            }

            HttpWebResponse _HttpWebResponse = (HttpWebResponse)_HttpWebRequest.GetResponse();

            using (Stream _Stream = _HttpWebResponse.GetResponseStream())
            {
                _DataSet.ReadXml(_Stream, XmlReadMode.InferSchema);
                _Stream.Close();
                return _DataSet;
            }
        }
    }
}
